package 真题;/**
 * @author： li
 * @date： 2022-04-07 21:10
 * @version 1.0
 */

import java.util.*;
public class 百亿富翁_普通写法 {
    static class da{
        private Integer l;
        private Integer r;
        public da() {

        }

        public void setL(int l) {
            this.l = l;
        }

        public void setR(int r) {
            this.r = r;
        }
    }
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int n= sc.nextInt();
        int[] a = new int[(int) (7e5+10)];
        for(int i=1;i<=n;i++)
            a[i]=sc.nextInt();
        da[] res = new da[n+10];
        for(int i=1;i<=n;i++){
            res[i] =new da();
            int j=i-1;
            while(j>=1&&a[j]<=a[i]) j--;
            res[i].setL(j==0?-1:j);
            j=j+1;
            while(j<=n&&a[j]<=a[i]) j++;
            res[i].setR(j==n+1?-1:j);
        }
        for(int i=1;i<=n;i++)
            System.out.print(res[i].l.toString()+" ");
        System.out.println();
        for(int j=1;j<=n;j++)
            System.out.print(res[j].r.toString()+" ");

    }
}
